<template>
  <div id="app">
    <P5>欢迎你，{{ $store.state.name }}</P5>
    <input type="button" value="通过mutations修改共享数据" @click="handleUpadte"/>
    <input type="button" value="通过actions修改共享数据" @click="handleCallAction"/>

    <!--视图组件展示的位置-->
    <!-- <router-view/> -->
  </div>
</template>

<script>
export default {
  methods: {
    handleUpadte() {
      // mutations中定义的函数不能直接调用 必须通过this这种方式调用
      // setName为mutations重定义的函数名称，
      this.$store.commit("setName", "lisi");
    },

    handleCallAction() {
      this.$store.dispatch('setNameByAxios');
    },
  
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav {
  padding: 30px;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style>